{extend name='table'}

{block name="content"}
<div class="layui-tab layui-tab-card" style="margin-top: 0;">
    <div class="layui-tab-content">
        {include file='goods/ozon/inventory/index_search'}
        <table id="inventoryTable" data-url="{:sysuri()}" data-target-search="form.form-search"></table>
    </div>
</div>
{/block}

{block name='script'}
<script>
    $(function () {
        let col_field = [
                {checkbox: true, fixed: true},
                {field: 'shop_name', title: '{:lang("店铺")}', minWidth: 100, align: 'center'},
                {field: 'goods_nu', title: '{:lang("SKU")}', minWidth: 160, align: 'center'},
                {field: 'warehouse_name', title: '{:lang("仓库")}', minWidth: 120, align: 'center'},
                {field: 'stock', title: '{:lang("库存数量")}', minWidth: 80, align: 'center'},
                {field: 'spu_code', title: '{:lang("SPU")}', minWidth: 120, align: 'center'},
                {field: 'spu_title', title: '{:lang("SPU名称")}', minWidth: 120, align: 'center'},
                {field: 'push_status_name', title: '{:lang("推送状态")}', minWidth: 100, align: 'center'},
                {field: 'create_at', title: '{:lang("添加时间")}', width: 160, align: 'center'},
            ]
        let account_show = '{$account_show|default=0}'
        if(account_show > 0){
            col_field.splice(1, 0, {field: 'account_name', title: '{:lang("公司")}', minWidth: 130, align: 'center'})
        }
        // 初始化表格组件
        $('#inventoryTable').layTable({
            even: true, height: 'full',toolbar: '#toolbar',
            cols: [col_field]
        });

    });
</script>

<script type="text/html" id="toolbar">
    <!--{if auth("pullStock")}-->
    <button  data-action='{:sysuri("pullStock")}' data-title="{:lang('同步库存')}"  class='layui-btn layui-btn-sm' data-rule="goods_nus#{goods_nu}" data-table-id="inventoryTable">{:lang('同步库存')}</button>
    <!--{/if}-->
    <!--{if auth("pushStock")}-->
    <button  data-action='{:sysuri("pushStock")}' data-title="{:lang('推送库存')}"  class='layui-btn layui-btn-sm layui-btn-normal' data-rule="sku_ids#{id}" data-table-id="inventoryTable">{:lang('推送库存')}</button>
    <!--{/if}-->
</script>
{/block}